package changechecker;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class FileToString {

    private FileReader file;
    private StringBuffer contents = new StringBuffer();
    private BufferedReader reader = null;

    public FileToString(String filename) {
        try {
            file = new FileReader(filename);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(FileToString.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            reader = new BufferedReader(file);
            String text = null;


            // repeat until all lines is read
            while ((text = reader.readLine()) != null) {
                contents.append(text).append(System.getProperty(
                        "line.separator"));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (reader != null) {
                    reader.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public String getString() {
        return contents.toString();
    }

    public String[] getArray() {
        return contents.toString().split("\n");
    }
}     
